<?php include_stylesheets_for_form($form) ?>
<?php include_javascripts_for_form($form) ?>

<form id="form_formulario" action="<?php echo url_for('formulario/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?id_dados_comerciais='.$form->getObject()->getIdDadosComerciais() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
<?php if (!$form->getObject()->isNew()): ?>
<input type="hidden" name="sf_method" value="put" />
<input type="hidden" name="id_dados_comerciais" value="<?php echo $form->getObject()->getIdDadosComerciais() ?>" />
<?php endif; ?>
	<?php echo $form->renderHiddenFields() ?>
  <table class="form">
    <tbody>
      <tr><th colspan="2" class="title">Dados formulario</th></tr>	
      <?php echo $form->renderGlobalErrors() ?>
      <tr>
        <th><?php echo $form['nm_empresa']->renderLabel() ?></th>
        <td>
          <?php echo $form['nm_empresa'] ?>
          <?php echo form_error('nm_empresa'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['id_usuario']->renderLabel() ?></th>
        <td>
          <?php echo $form['id_usuario'] ?>
          <?php echo form_error('id_usuario'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['nu_cep']->renderLabel() ?></th>
        <td>
          <?php echo $form['nu_cep'] ?>
          <?php echo form_error('nu_cep'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['logradouro']->renderLabel() ?></th>
        <td>
          <?php echo $form['logradouro'] ?>
          <?php echo form_error('logradouro'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['logradouro_numero']->renderLabel() ?></th>
        <td>
          <?php echo $form['logradouro_numero'] ?>
          <?php echo form_error('logradouro_numero'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['logradouro_complemento']->renderLabel() ?></th>
        <td>
          <?php echo $form['logradouro_complemento'] ?>
          <?php echo form_error('logradouro_complemento'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['bairro']->renderLabel() ?></th>
        <td>
          <?php echo $form['bairro'] ?>
          <?php echo form_error('bairro'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['cidade']->renderLabel() ?></th>
        <td>
          <?php echo $form['cidade'] ?>
          <?php echo form_error('cidade'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['sg_uf']->renderLabel() ?></th>
        <td>
          <?php echo $form['sg_uf'] ?>
          <?php echo form_error('sg_uf'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['estado']->renderLabel() ?></th>
        <td>
          <?php echo $form['estado'] ?>
          <?php echo form_error('estado'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['nu_cnpj']->renderLabel() ?></th>
        <td>
          <?php echo $form['nu_cnpj'] ?>
          <?php echo form_error('nu_cnpj'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['st_atividade']->renderLabel() ?></th>
        <td>
          <?php echo $form['st_atividade'] ?>
          <?php echo form_error('st_atividade'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['tp_atividade']->renderLabel() ?></th>
        <td>
          <?php echo $form['tp_atividade'] ?>
          <?php echo form_error('tp_atividade'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['nu_funcionarios']->renderLabel() ?></th>
        <td>
          <?php echo $form['nu_funcionarios'] ?>
          <?php echo form_error('nu_funcionarios'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['tel_fixo']->renderLabel() ?></th>
        <td>
          <?php echo $form['tel_fixo'] ?>
          <?php echo form_error('tel_fixo'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['tel_fixo_extra']->renderLabel() ?></th>
        <td>
          <?php echo $form['tel_fixo_extra'] ?>
          <?php echo form_error('tel_fixo_extra'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['ds_atividade']->renderLabel() ?></th>
        <td>
          <?php echo $form['ds_atividade'] ?>
          <?php echo form_error('ds_atividade'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['icms']->renderLabel() ?></th>
        <td>
          <?php echo $form['icms'] ?>
          <?php echo form_error('icms'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['created_at']->renderLabel() ?></th>
        <td>
          <?php echo $form['created_at'] ?>
          <?php echo form_error('created_at'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['updated_at']->renderLabel() ?></th>
        <td>
          <?php echo $form['updated_at'] ?>
          <?php echo form_error('updated_at'); ?>
        </td>
      </tr>
    </tbody>
  </table>
</form>

<?php 
	comandos_form(
		link_to(
			':: Voltar ::',
			'formulario/filter',
			array('class' => 'botao')
		),
		button_to_function(
			':: Salvar ::',
			"$('#form_formulario').submit()",
			array('class' => 'botao')
		)
	);
?>